<template>
    <div class="container" @click="handleGallryClick">
      <div class="wrapper">
        <swiper :options="swiperOptions">
          <!-- slides -->
          <swiper-slide v-for="(item, index) in imgs" :key="index">
            <img class="gallary-img" :src="item">
          </swiper-slide>
          <!-- Optional controls -->
        </swiper>
        <div class="swiper-pagination pagination"  slot="pagination"></div>
      </div>
    </div>
</template>

<script>
export default {
  name: 'CommonGallary',
  props: {
    imgs: {
      type: Array,
      default () {
        // return ['//img1.qunarzz.com/sight/p0/1711/fe/fe517fa5a183e4bca3.img.jpg_600x330_a413e5b1.jpg', 'http://img1.qunarzz.com/sight/p0/1711/f7/f714e5736f6ba7c9a3.img.jpg_r_800x800_ac31e249.jpg']
        return []
      }
    }
  },
  data () {
    return {
      swiperOptions: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        observeParents: true,
        observer: true
      }
    }
  },
  methods: {
    handleGallryClick () {
      this.$emit('close')
    }
  }
}
</script>

<style scoped>
  .container{
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
  }
  .swiper-contaier{
    overflow: inherit;
  }
  .wrapper{
    width: 100%;
    height: 0;
    padding-bottom: 100%;
  }
  .gallary-img{
    width: 100%;
  }
  .pagination{
    color: #ffffff;
    position: absolute;
    bottom: 20%;
    left: 0;
  }
</style>
